package com.hncboy.chatgpt.front.api.redisTemplate;
import com.hncboy.chatgpt.front.service.impl.KeyServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;


@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate<String, KeyServiceImpl.KeyInfo> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, KeyServiceImpl.KeyInfo> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        redisTemplate.setDefaultSerializer(new Jackson2JsonRedisSerializer<>(KeyServiceImpl.KeyInfo.class));
        return redisTemplate;
    }
}
